<?php

namespace DC\UserCenter\Models;

use App\Models\BaseModel;
use DC\UserCenter\Models\Traits\ReferrerUser;

class UserBaseModel extends BaseModel
{
    use ReferrerUser;
    protected $table = 'users_base';

    protected $primaryKey = 'member_id';

    public $dateFormat = 'U';

    protected $dates = [
        'created_at',
        'updated_at',
        'activated_at'
    ];

    public function auth()
    {
        return $this->hasOne('DC\UserCenter\Models\UserAuthModel','member_id','member_id');
    }

    public function info()
    {
        return $this->hasOne('DC\UserCenter\Models\UserInfoModel','member_id','member_id');
    }
    public function referrer()
    {
        return $this->hasOne('DC\UserCenter\Models\UserBaseModel','member_id','referrer_id');
    }
    public function jiedian()
    {
        return $this->hasOne('DC\UserCenter\Models\UserBaseModel','member_id','jiedian_id');
    }
    public function bdr()
    {
        return $this->hasOne('DC\UserCenter\Models\UserBaseModel','member_id','bd_uid');
    }

    public function wallet()
    {
        return $this->hasOne('DC\UserCenter\Models\UserWalletModel','member_id','member_id');
    }

    public function children()
    {
        return $this->hasMany('DC\UserCenter\Models\UserBaseModel','referrer_id','member_id');
    }
    public function jiedianchildren()
    {
        return $this->hasMany('DC\UserCenter\Models\UserBaseModel','jiedian_id','member_id');
    }


}
